<template>
	<!-- 照会白名单工作列表-照会白名单配置信息页面 -->
	<div class="fillcontain">
		<el-form :model="searchParams" ref="ruleForm" label-width="130px" class="search_container">
			<el-row>
				<el-col :span="5">
					<el-form-item label="被保人证件号码" prop="secuityno">
						<el-input v-model="searchParams.secuityno" placeholder="请输入被保人证件号码" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="5">
					<el-form-item label="投保起始日" prop="currfrom">
						<el-date-picker v-model="searchParams.currfrom" type="date" value-format="yyyyMMdd" format="yyyy-MM-dd" placeholder="请选择投保起始日" @change="clearTimeSetDefault">
						</el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="5">
					<el-form-item label="投保终止日" prop="currto">
						<el-date-picker v-model="searchParams.currto" type="date" value-format="yyyyMMdd" format="yyyy-MM-dd" placeholder="投保终止日" @change="clearTimeSetDefault">
						</el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="5">
					<el-form-item label="主合同代码" prop="crtable">
						<el-input v-model="searchParams.crtable" placeholder="请输入主合同代码" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="4" class="text_center">
					<el-button type="primary" icon="el-icon-search" @click="search"></el-button>
					<el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
				</el-col>
			</el-row>
		</el-form>
		<div class="contain">
			<div class="table_container">
				<el-button type="danger" @click="addMessageHandle" style="margin: 0px 0px 20px 20px;">新增</el-button>
				<el-form ref="tableForm" :model="tableForm">
					<el-table v-loading="loading" :data="tableForm.tableData" highlight-current-row header-cell-class-name="table-header-class" :row-style="rowStyle"
					style="width:100%">
						<el-table-column min-width="100" property="seqNumber" label="序号" align='center' sortable  show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.seqNumber'">
									<el-input disabled v-model="tableForm.tableData[scope.$index].seqNumber" placeholder=""></el-input>
								</el-form-item>
								<span v-else>{{ scope.row.seqNumber || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="120" property="surname" label="被保人姓名" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :rules="formRules.surname" :prop="'tableData.' + scope.$index + '.surname'">
									<el-input :disabled="surnameDis" v-model="tableForm.tableData[scope.$index].surname" placeholder="请输入被保人姓名" clearable></el-input>
								</el-form-item>
								<span v-else>{{ scope.row.surname || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="200" property="secuityno" label="被保人证件号码" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :rules="formRules.secuityno" :prop="'tableData.' + scope.$index + '.secuityno'">
									<el-input :disabled="surnameDis" v-model="tableForm.tableData[scope.$index].secuityno" @blur="insuredidIdentify(scope.row,scope.$index)" placeholder="请输入被保人证件号码" maxlength="24" clearable></el-input>
								</el-form-item>
								<span v-else>{{ scope.row.secuityno || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="90" property="cltsex" label="被保人性别" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<!-- <el-input v-if="!scope.row.disabled" v-model="tableData[scope.$index].cltsex" placeholder="请输入被保人性别"></el-input> -->
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.cltsex'">
									<el-select :disabled="surnameDis" v-model="tableForm.tableData[scope.$index].cltsex" placeholder="" clearable>
										<el-option v-for="item in sexOpt" :key="item.value" :label="item.name" :value="item.value">
										</el-option>
									</el-select>
								</el-form-item>
								<span v-else>{{ scope.row.cltsexCHN || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="150" property="cltdob" label="被保人出生日期" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.cltdob'">
									<el-date-picker :disabled="surnameDis" v-model="tableForm.tableData[scope.$index].cltdob" type="date" value-format="yyyyMMdd" format="yyyy-MM-dd" placeholder="请输入被保人出生日期" @change="clearTimeSetDefault">
									</el-date-picker>
								</el-form-item>
								<span v-else>{{ scope.row.cltdobSub|| "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="150" property="currfrom" label="投保起始日" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.currfrom'">
									<el-date-picker v-model="tableForm.tableData[scope.$index].currfrom" type="date" value-format="yyyyMMdd" format="yyyy-MM-dd" placeholder="请选择投保起始日" @focus="timeFromHandle(scope.row)" @change="clearTimeSetDefault">
									</el-date-picker>
								</el-form-item>
								<span v-else>{{ scope.row.currfromSub || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="150" property="currto" label="投保终止日" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.currto'">
									<el-date-picker v-model="tableForm.tableData[scope.$index].currto" type="date" value-format="yyyyMMdd" format="yyyy-MM-dd" placeholder="请选择投保终止日" @focus="timeToHandle(scope.row)" @change="clearTimeSetDefault">
									</el-date-picker>
								</el-form-item>
								<span v-else>{{ scope.row.currtoSub || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="180" property="crtable" label="主合同代码（crtable）" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.crtable'">
									<el-input :rules="formRules.crtable" :disabled="surnameDis" v-model="tableForm.tableData[scope.$index].crtable" placeholder="请输入主合同代码（crtable）" clearable maxlength="4"></el-input>
								</el-form-item>
								<span v-else>{{ scope.row.crtable || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="220" property="notedesc" label="主合同名称" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.notedesc'">
									<el-input v-model="tableForm.tableData[scope.$index].notedesc" placeholder="请输入主合同名称" clearable maxlength="256"></el-input>
								</el-form-item>
								<span v-else>{{ scope.row.notedesc || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="220" property="sremark" label="抹除的照会代码" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-form-item v-if="!scope.row.disabled" :prop="'tableData.' + scope.$index + '.sremark'">
									<el-input v-model="tableForm.tableData[scope.$index].sremark" placeholder="请输入抹除的照会代码" @blur="sremarkFormat(scope.row.sremark)" clearable maxlength="256"></el-input>
								</el-form-item>
								<span v-else>{{ scope.row.sremark || "--" }}</span>
							</template>
						</el-table-column>
						<el-table-column min-width="200" property="recognizeeName" label="操作" align='center' show-overflow-tooltip>
							<template slot-scope="scope">
								<el-button type="text" size="small" @click="copyMessageHandle(scope.row)" v-if="scope.row.disabled">复制</el-button>
								<el-button type="text" size="small" @click="updateMessageHandle(scope.row)" v-if="scope.row.disabled">修改</el-button>
								<el-button type="text" size="small" @click="saveMessageHandle(scope.row,scope.$index)" v-if="!scope.row.disabled">保存</el-button>
								<el-button type="text" size="small" @click="deleteMessageHandle(scope.row)">删除</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-form>
				<el-row>
					<el-col :span="24">
						<div class="pagination">
							<el-pagination background v-if='paginations.total > 0' :page-sizes="paginations.pageSizes" :page-size="paginations.pageSize"
							 :layout="paginations.layout" :total="paginations.total" :current-page='paginations.pageIndex' @current-change='handleCurrentChange'
							 @size-change='handleSizeChange'>
							</el-pagination>
						</div>
					</el-col>
				</el-row>
			</div>
		</div>
	</div>
</template>

<script> 
	import transformation from "@/utils/transformation/qualityInspection"; // 数据翻译
	import {
		mapGetters
	} from 'vuex'
	import constant from '@/utils/constant'; // 通用参数
	import {getSsyOrgMap,warnOutSty} from '@/api/taskCenter/taskCommon'; // 任务中心接口定义
	import TaskConstants, {
		call
	} from "@/api/taskManager/common" // 通用AXIOS请求：GET/POST
	import {
		queryEUBKPFListConfigApi,addOrUpdateEUBKPFConfigApi,delEUBKPFListConfigApi
	} from "@/api/setting/maintain/messageSafe"; //调接口
	import { getToken } from '@/utils/auth' // 验权(从cookie中获取)
import { debug } from 'console';

	export default {
		name:'messageSafe',
		data() {
			var validSurname = (rule, value, callback) => {
				if (value === "" || value == undefined) {
					callback(new Error("被保人姓名不能为空!"));
				} else {
					callback();
				}
			};
			var validSecuityno = (rule, value, callback) => {
				if (value === "" || value == undefined) {
					callback(new Error("被保人证件号码不能为空!"));
				} else {
					callback();
				}
			};
			var validCrtable = (rule, value, callback) => {
				if (value === "" || value == undefined) {
					callback(new Error("主合同代码（crtable）不能为空!"));
				} else {
					callback();
				}
			};
			return {
				changeTaskNo: "",
				surnameDis : false, // 禁用被保人输入框，不允许修改
				searchParams : {
					currfrom : "",
					currto : "",
					crtable : "",
					// sremark : ""
					secuityno : ""
				}, // 白名单搜索对象
				preTasks: TaskConstants.preTasks,
				preChannels: TaskConstants.preChannelType,
				emptySearchParams: {},
				tableForm:{
					tableData: []
        },
				formRules : {
					surname: [{ validator: validSurname, trigger: "blur" }],
					secuityno: [{ validator: validSecuityno, trigger: "blur" }],
					crtable: [{ validator: validCrtable, trigger: "blur" }]
				},
				ssyMap:{},
				loading: false,
				//需要给分页组件传的信息
				paginations: {
					total: 0, // 总数
					pageIndex: 1, // 当前位于哪页
					pageSize: 10, // 1页显示多少条
					pageSizes: [5, 10, 15, 20], //每页显示多少条
					layout: "total, sizes, prev, pager, next, jumper" // 翻页属性
				},
				addOrUpFlag : false, // 消息作业数据添加或修改标志
				currentId : "", // 新增/修改/复制时，需要将当前id或序号赋值，避免保存时点击不同的数据导致出现bug
				userInfo:{}, // 存储用户信息
				sexOpt : [{
					name:'男',
					value:'M'
				},{
					name:'女',
					value:'F'
				}], // 性别选项
				insuredidCheckStatus : false, //身份证校验是否通过
				sremarkCheckStatus : false, //照会代码校验是否通过
				aCity: {
                    11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海",
                    32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南",
                    44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西",
                    62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外"
                }, // 城市
				// oldRowData : {}, // 白名单旧数据，修改时需要将旧的数据放进data里面，否则修改会出问题
			}
		},
		// activated(){
		// 	this.search();
		//     document.onkeydown = (event)=>{
		//         var e = event || window.event || arguments.callee.caller.arguments[0];
		//         if (e && e.keyCode == 113) {
		//             this.search();
		//         }
		//     };
		// }, 
		created() {
			this.userInfo = JSON.parse(localStorage.getItem(getToken('token'))).userKeyInfo;
			// 初始化searchParams复制给emptySearchParams，减少代码重复
			this.emptySearchParams = JSON.parse(JSON.stringify(this.searchParams));
		},
		mounted() {
			// getSsyOrgMap().then(data => this.ssyMap = data);
			this.getList();
		},
		methods: {
			rowStyle({ row, rowIndex}) {
				return warnOutSty(row,this.nodeMap);
			},
			// 清空时间
			clearTimeSetDefault(val) {
				if (val == null) {
					val = '';
				}
			},
			timeFromHandle(row){
				if(row.currfrom != '' && row.currfrom != null && row.currfrom != undefined && row.currto != '' && row.currto != null && row.currto != undefined){
					if(row.currfrom > row.currto){
						this.$message({message: "投保起始日不能大于投保终止日",type: "warning",showClose: true});
						return ;
					}
				}
			},
			timeToHandle(row){
				if(row.currfrom != '' && row.currfrom != null && row.currfrom != undefined && row.currto != '' && row.currto != null && row.currto != undefined){
					if(row.currfrom > row.currto){
						this.$message({message: "投保起始日不能大于投保终止日",type: "warning",showClose: true});
						return ;
					}
				}
			},
			// 新增消息白名单表格
			addMessageHandle(){
				if(this.addOrUpFlag == true){
					this.$message({
						message: "只能新增一条数据，请保存或取消后再试！",
						type: "warning",
						showClose: true,
					});
					return ;
				}
				// 新增/修改标志开启
				this.addOrUpFlag = true;
				// 保存序号在currentId，可以在保存时使用
				this.currentId = "";
				// 开启被保人输入框
				this.surnameDis = false;
				this.tableForm.tableData.push({
					"seqNumber" : "",
					"notedesc": "",
					"surname" : "",
					"secuityno" : "",
					"cltsex":"",
					"cltdob":"",
					"currfrom" : "",
					"currto" : "",
					"sremark" : "",
					"crtable":""
				});
			},
			// 保存消息白名单
			saveMessageHandle(row,index){
				if(this.currentId != row.seqNumber){
					this.$message({
						message: "请勿点击其他数据进行保存！",
						type: "warning",
						showClose: true,
					});
					return ;
				}
				if(row.surname == '' || row.surname == undefined){
					this.$message({
						message: "被保人名称不能为空",
						type: "warning",
						showClose: true,
					});
					return ;
				}
				if(row.secuityno == '' || row.secuityno == undefined){
					this.$message({
						message: "被保人证件号码不能为空",
						type: "warning",
						showClose: true,
					});
					return ;
				}
				if(row.crtable == '' || row.crtable == undefined){
					this.$message({
						message: "主合同代码不能为空",
						type: "warning",
						showClose: true,
					});
					return ;
				}
				if(row.sremark == '' || row.sremark == undefined){
					this.$message({
						message: "抹除的照会代码不能为空",
						type: "warning",
						showClose: true,
					});
					return ;
				}
				if(row.currfrom != '' && row.currfrom != null && row.currfrom != undefined && row.currto != '' && row.currto != null && row.currto != undefined){
					if(row.currfrom > row.currto){
						this.$message({message: "投保起始日不能大于投保终止日",type: "warning",showClose: true});
						return ;
					}
				}
				this.sremarkFormat(row.sremark);
				// seqNumber序号为空说明是新增，不为空则为修改数据
				// this.insuredidIdentify(row,index); // 身份证校验，校验不通过不能保存
				if(this.sremarkCheckStatus == true){
					let oldRowData = JSON.parse(sessionStorage.getItem(row.seqNumber+row.surname+"oldRowData"));
					if(oldRowData != null){
						if(oldRowData.secuityno != undefined){
							row.oldSecuityno = oldRowData.secuityno;
							row.oldSurname = oldRowData.surname;
							row.oldCltsex = oldRowData.cltsex;
							row.oldCrtable = oldRowData.crtable;
							row.oldNotedesc = oldRowData.notedesc;
							row.oldSremark = oldRowData.sremark;
						}
					}
					addOrUpdateEUBKPFConfigApi(row).then((res) => {
						if (res.resultCode === 0) {
							this.$store.dispatch("loading/CHANGE_LOADING", false);
							// 保存成功后新增/修改标志需关闭
							this.addOrUpFlag = false;
							// 保存成功后清除oldRowData数据
							// this.oldRowData = {};
							this.insuredidCheckStatus = false;
							this.sremarkCheckStatus = false;
							sessionStorage.removeItem(row.seqNumber+row.surname+"oldRowData");
							this.$message({message: ((row.seqNumber != '' && row.seqNumber != null && row.seqNumber != undefined) ? "修改" : "保存") + "消息白名单数据成功！",type: "success",showClose: true});
							// 调用查询接口
							this.getList();
						}else{
							this.$store.dispatch("loading/CHANGE_LOADING", false);
							// this.$message({message: res.resultMsg,type: "warning",showClose: true});
						}
					}).catch((err) => {
						this.$store.dispatch("loading/CHANGE_LOADING", false);
						this.$message({message: "保存消息白名单配置数据异常",type: "warning",showClose: true});
					});
				}		
			},
			// 删除消息白名单
			deleteMessageHandle(row){
				this.$confirm(`确定进行删除操作?`, "提示", {
					confirmButtonText: "确定",
					cancelButtonText: "取消",
					type: "warning",
				}).then(() => {
					// 调用删除接口
					if(row.seqNumber != null && row.seqNumber != '' && row.seqNumber != undefined){
						// 重置编辑状态
						row.disabled = true;
						delEUBKPFListConfigApi(row).then((res) => {
							if (res.resultCode === 0) {
								this.$store.dispatch("loading/CHANGE_LOADING", false);
								// 保存成功后新增/修改标志需关闭
								this.addOrUpFlag = false;
								this.$message({message: "删除消息白名单数据成功！",type: "success",showClose: true});
								// 调用查询接口
								this.getList();
							}else{
								this.$store.dispatch("loading/CHANGE_LOADING", false);
								this.$message({message: res.resultMsg,type: "warning",showClose: true});
							}
						}).catch((err) => {
							this.$store.dispatch("loading/CHANGE_LOADING", false);
							this.$message({message: "删除消息白名单配置数据异常",type: "warning",showClose: true});
						});
					}else{
						// 方案一，若出现bug，则改为直接刷页面
						this.tableForm.tableData.pop(); //直接移除push以后的数据
					}
					// 取消后新增/修改标志需关闭
					this.addOrUpFlag = false;
				});
			},
			copyMessageHandle(row){
				if(this.addOrUpFlag == true){
					this.$message({message: "只能新增一条数据，请保存或取消后再试！",type: "warning",showClose: true});
					return ;
				}
				// 新增/修改标志开启
				this.addOrUpFlag = true;
				// 保存序号在currentId，可以在保存时使用
				this.currentId = "";
				let copyObj = {
					seqNumber: "",
					cltsex: row.cltsex,
					cltdob: row.cltdob,
					surname : row.surname,
					secuityno:row.secuityno,
					currfrom: row.currfrom,
					currto: row.currto,
					sremark: row.sremark,
					crtable: row.crtable,
					notedesc: row.notedesc
				};
				this.tableForm.tableData.push(copyObj);
			},
			updateMessageHandle(row){
				if(this.addOrUpFlag == true){
					this.$message({message: "只能新增一条数据，请保存或取消后再试！",type: "warning",showClose: true});
					return ;
				}
				// 新增/修改标志开启
				this.addOrUpFlag = true;
				// 禁用被保人输入框
				this.surnameDis = true;
				// 保存序号在currentId，可以在保存时校验是否是当前编辑的数据
				this.currentId = row.seqNumber;
				// 禁用按钮开启
				row.disabled = false;
				// 赋值旧数据给oldRowData
				window.sessionStorage.setItem(row.seqNumber+row.surname+"oldRowData", JSON.stringify(row));
			},
			// 数据转换
			transformationFun(type, status) {
				return transformation.transformation(type, status);
			},
			getOrgName(value) {
				// for (var key in this.ssyMap) {
				// 	if (this.ssyMap[key]["sbusiorgid"] && this.ssyMap[key]["sbusiorgid"] == value) {
				// 		value = this.ssyMap[key]["sorgname"]
				// 		break;
				// 	}
				// }
				// return value;
			},
			getChannelName(value) {
				// for (var key in this.preChannels) {
				// 	if (this.preChannels[key]["key"] && this.preChannels[key]["key"] == value) {
				// 		value = this.preChannels[key]["name"]
				// 		break;
				// 	}
				// }
				// return value;
			},
			getRoute(value) {
				// for (var key in this.preTasks) {
				// 	if (this.preTasks[key]["value"] && this.preTasks[key]["value"] == value) {
				// 		value = this.preTasks[key]["name"]
				// 		break;
				// 	}
				// }
				// return value;
			},
			hideChange() {
				this.changeTaskNo = "";
			},
			// 综合查询列表
			getList() {
				// if(this.searchParams.currfrom != '' && this.searchParams.currfrom != null && this.searchParams.currfrom != undefined && this.searchParams.currto != '' && this.searchParams.currto != null && this.searchParams.currto != undefined){
				// 	if(this.searchParams.currfrom > this.searchParams.currto){
				// 		this.$message({message: "投保起始日不能大于投保终止日",type: "warning",showClose: true});
				// 		return ;
				// 	}
				// }
				this.paginations.total = 0;
				this.searchParams.pageNum = this.paginations.pageIndex;
				this.searchParams.pageSize = this.paginations.pageSize;
				this.$store.dispatch('loading/CHANGE_LOADING', true)
				queryEUBKPFListConfigApi(this.searchParams).then((res) => {
					if (res.resultCode === 0) {
						this.$store.dispatch("loading/CHANGE_LOADING", false);
						if(res.data.total > 0){
							let newDataList = res.data.list;
							newDataList.forEach((e)=>{
								e.disabled = true; // 用于判断数据编辑状态还是查看状态
								e.cltsex = e.cltsex.replace(/\s/g,""); // 去除空格
								if(e.cltsex != '' && e.cltsex != undefined){
									e.cltsexCHN = this.transformationFun("cltsex",e.cltsex);
								}
								e.clntnum = e.clntnum.replace(/\s/g,""); // 去除空格
								e.notedesc = e.notedesc.replace(/\s/g,""); // 去除空格
								e.secuityno = e.secuityno.replace(/\s/g,""); // 去除空格
								e.sremark = e.sremark.replace(/\s/g,""); // 去除空格
								e.surname = e.surname.replace(/\s/g,""); // 去除空格
								// 日期为0说明为空
								if(e.cltdob == 0){
									e.cltdobSub = "";
								}else{
									e.cltdob = e.cltdob.toString();
									let cltdobData = e.cltdob.toString();
									e.cltdobSub = cltdobData.substring(0,4)+"-"+cltdobData.substring(4,6)+"-"+cltdobData.substring(6,8);
								}
								if(e.currfrom == 0){
									e.currfrom = "";
									e.currfromSub = "";
								}else{
									e.currfrom = e.currfrom.toString();
									let currfromData = e.currfrom.toString();
									e.currfromSub = currfromData.substring(0,4)+"-"+currfromData.substring(4,6)+"-"+currfromData.substring(6,8);
								}
								if(e.currto == 0){
									e.currto = "";
									e.currtoSub = "";
								}else{
									e.currto = e.currto.toString();
									let currtoData = e.currto.toString();
									e.currtoSub = currtoData.substring(0,4)+"-"+currtoData.substring(4,6)+"-"+currtoData.substring(6,8);
								}
							})
							this.tableForm.tableData = newDataList;
						}else{
							this.tableForm.tableData = [];
						}
						this.paginations.total = res.data.total;
					}else{
						this.$store.dispatch("loading/CHANGE_LOADING", false);
						this.$message({message: res.resultMsg,type: "warning",showClose: true});
					}
				}).catch((err) => {
					console.log(err);
					this.$store.dispatch("loading/CHANGE_LOADING", false);
					this.$message({message: "查询消息白名单配置数据异常",type: "warning",showClose: true});
				});
			},
			// 每页多少条切换
			handleSizeChange(pageSize) {
				this.addOrUpFlag = false;
				this.paginations.pageSize = pageSize;
				this.getList();
			},
			// 上下分页
			handleCurrentChange(page) {
				this.addOrUpFlag = false;
				this.paginations.pageIndex = page;
				this.getList();
			},
			// 根据条件查询列表
			search() {
				this.paginations.pageIndex = 1;
				this.getList();
			},
			// 清除查询条件
			resetSearch() {
				this.searchParams = JSON.parse(JSON.stringify(this.emptySearchParams));
			},
			//检查身份证号是否合法
            checkIdno(id) {
                let id_length = id.length;
                if (id_length != 15 && id_length != 18) {
                    return null;
                }
                // if (this.aCity[Number(id.substr(0, 2))] == null) {
                //     return null;
                // }
                return "";
            },
			// 格式校验
			sremarkFormat(row){
				// 检验格式
				let rowData = row;
				let exp = /^[A-Za-z0-9;]+$/;
				if (!exp.test(rowData)) {
					this.sremarkCheckStatus = false;
					this.$message({message: "抹除照会代码必须是三位英文/数字或两者的组合",type: "warning",showClose: true});
					return ;
				}
				let arr = rowData.split(";");
				arr.forEach((e)=>{
					if(e.length == 3){
						this.sremarkCheckStatus = true;
					}else{
						this.sremarkCheckStatus = false;
						this.$message({message: "注意！抹除照会代码必须是三位",type: "warning",showClose: true});
						return ;
					}
				})
			},
			// 身份证证件校验
			insuredidIdentify(row,indexs){
				let iden = row.secuityno;
                if (iden.length > 0) {
                    // let idCheck = this.checkIdno(iden);
                    // if (idCheck == null) {
					// 	this.$message({message: "注意！身份证信息不合法",type: "warning",showClose: true});
					// 	this.insuredidCheckStatus = false;
                    //     return;
                    // }
					let birth = "";
                    if (iden.length == 15) {
                        birth = "19" + iden.substring(6, 8) + iden.substring(8, 10) + iden.substring(10, 12);
                        // if(row.cltdob != '' && row.cltdob != null){
						// 	if (row.cltdob != birth) {
						// 		this.$message({message: "注意！出生日期与身份证号码不匹配",type: "warning",showClose: true});
						// 		this.insuredidCheckStatus = false;
						// 		return;
						// 	}
						// }
                    }
                    if (iden.length == 18) {
                        birth = iden.substring(6, 10) + iden.substring(10, 12) + iden.substring(12, 14);
                        // if (iden.indexOf("X") > 0 && iden.indexOf("X") != 17 || iden.indexOf("x") > 0 && iden.indexOf("x") != 17) {
                        //     this.$message({message: "注意！身份证信息不合法",type: "warning",showClose: true});
                        //     this.insuredidCheckStatus = false;
						// 	return;
                        // }
                        // if (iden.substring(6, 10) > 2200 || iden.substring(6, 10) < 1900) {
                        //     this.$message({message: "注意！身份证信息不合法",type: "warning",showClose: true});
						// 	this.insuredidCheckStatus = false;
						// 	return;
                        // }
                    }
					let sexNew = "";
                    if (iden.length == 18 ? iden.substring(16).substring(0, 1) % 2 == 0 : iden.substring(14).substring(0, 1) % 2 == 0) {
                        sexNew = "F";
                    } else {
                        sexNew = "M";
                    }
					// if(row.cltsex != '' && row.cltsex != null){
					// 	if (row.cltsex != sexNew) {
					// 		this.insuredidCheckStatus = false;
					// 		this.$message({message: "注意！性别与身份证号码不匹配",type: "warning",showClose: true});
					// 		return;
					// 	}
					// }
					// 年龄、性别赋值
					this.tableForm.tableData[indexs].cltsex = sexNew;
					this.tableForm.tableData[indexs].cltdob = birth;
                    // if (iden.charAt(17) == "x" || iden.charAt(17) == "X") {
                    //     if ("x" != this.GetVerifyBit(iden) && "X" != this.GetVerifyBit(iden)) {
					// 		this.insuredidCheckStatus = false;
                    //         this.$message({message: "身份证校验错误，请检查最后一位！",type: "warning",showClose: true});
                    //         return;
                    //     }
                    // } else {
                    //     if (iden.charAt(17) != this.GetVerifyBit(iden)) {
					// 		this.insuredidCheckStatus = false;
                    //         this.$message({message: "身份证校验错误，请检查最后一位！",type: "warning",showClose: true});
                    //         return;
                    //     }
                    // }
					this.insuredidCheckStatus = true;
                }
			},
			// 身份证15位转18位中,计算校验位即最后一位
            GetVerifyBit(id) {
                var result;
                var nNum = eval(id.charAt(0) * 7 + id.charAt(1) * 9 + id.charAt(2) * 10 + id.charAt(3) * 5 + id.charAt(4) * 8 + id.charAt(5) * 4 + id.charAt(6) * 2 + id.charAt(7) * 1 + id.charAt(8) * 6 + id.charAt(9) * 3 + id.charAt(10) * 7 + id.charAt(11) * 9 + id.charAt(12) * 10 + id.charAt(13) * 5 + id.charAt(14) * 8 + id.charAt(15) * 4 + id.charAt(16) * 2);
                nNum = nNum % 11;
                switch (nNum) {
                    case 0 :
                        result = "1";
                        break;
                    case 1 :
                        result = "0";
                        break;
                    case 2 :
                        result = "X";
                        break;
                    case 3 :
                        result = "9";
                        break;
                    case 4 :
                        result = "8";
                        break;
                    case 5 :
                        result = "7";
                        break;
                    case 6 :
                        result = "6";
                        break;
                    case 7 :
                        result = "5";
                        break;
                    case 8 :
                        result = "4";
                        break;
                    case 9 :
                        result = "3";
                        break;
                    case 10 :
                        result = "2";
                        break;
                }
                return result;
            },
		},
		computed: {
			...mapGetters(['tags']),
			reload() {
				return this.$store.state.loading.reload;
			}
		},
		// activated() {
		// 	if (this.reload) {
		// 		this.$store.dispatch('loading/CHNAGE_RELOAD', false)
		// 		Object.assign(this.$data, this.$options.data());
		// 	}
		// 	document.onkeydown = (event)=>{
		// 		var e = event || window.event || arguments.callee.caller.arguments[0];
		// 		if (e && e.keyCode == 113) {
		// 			this.getList();
		// 		}
		// 	};
		// }
	}
</script>

<style lang="less" scoped>
	.fillcontain {
		padding-bottom: 0;
	}

	.contain {
		background: #fff;
		padding: 10px;
		margin-bottom: 20px;
	}

	.pagination {
		padding: 10px 20px;
		text-align: right;
	}

	.operationIcon {
		// padding: 12px;
		border: 1px solid #e5e5e5;
		border-radius: 50%;
		width: 22px;
		height: 22px;
		display: inline-block;
		cursor: pointer;
		box-shadow: 0 0 3px #f9f9f9;

		.svg-icon {
			font-size: 14px;
			fill: #68a3fc;
		}
	}

	.search_container {
		padding: 20px 20px 0 20px;
		border-top: 1px solid #e1e1e1;
	}
</style>
